During a call process, when a first electronic device plays a speech signal sent by a second electronic device, a microphone in the first electronic device collects the speech signal, and sends the speech signal to the second electronic device. Consequently, a user of the second electronic device hears an echo of the speech signal from the user, affecting call quality. Therefore, it is necessary to cancel the echo during the call process.
In related technologies, an echo cancellation method is provided. First, a first electronic device inputs a far-end signal and a near-end signal to a double-end detection module of the first electronic device. The far-end signal is a speech signal sent by a second electronic device, and the near-end signal is a mixed signal including an echo signal generated when the first electronic device plays the far-end signal and a speech signal from a user of the first electronic device. The double-end detection module detects whether a speech signal exists in the near-end signal, inputs a detection result and the far-end signal to a normalized least mean square adaptive filtering (NLMS) module, obtains an estimated signal of the far-end signal according to the far-end signal and outputs the estimated signal, and then subtracts the estimated signal from the near-end signal to obtain a residual signal. The residual signal is inputted to a non-linear processing (NLP) module to reduce the echo signal when the detection result received by the NLMS module is that the speech signal exists in the near-end signal, to improve an effect of echo cancellation. The residual signal is inputted to the NLMS module when the detection result received by the NLMS module is that no speech signal exists in the near-end signal, and the residual signal is used for estimation of the far-end signal for the next time.
Because there is certain error when the NLMS module estimates the far-end signal, a part of the echo signal remains in the residual signal obtained by subtracting the estimated signal from the near-end signal, affecting call quality.